<?php
/**
 * Created by PhpStorm.
 * User: liyalong
 * Date: 2018/8/13
 * Time: 上午10:30
 */

namespace Modules\Base;


use Houdunwang\WeChat\WeChat;
use Modules\Base\Entities\BaseReply;

class Respons
{
    /**
     *
     * 处理微信回复
     *
     * @param $data 规则数据
     */
    public function handle($data)
    {
        //消息管理模块
        $instance = WeChat::instance('message');
//关注用户扫描二维码事件
        //通过传递过来的规则数据找到对应的回复内容数据
        $content = json_decode(BaseReply::where('rule_id',$data['id'])->first()->content,true);
        //向用户回复消息
        return $instance->text(array_random($content)['content']);

    }
}